package com.yyx.app1.MedicationAssistant_function.Controls.SearchDrup_Activity_Control.HotSearch_ListView;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.Html;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yyx.app1.Data.BaseDataManager;
import com.yyx.app1.Data.testDate;
import com.yyx.app1.R;
import com.yyx.app1.tool.ImageTool;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by yuexing on 2015/10/14.
 */
@EViewGroup(R.layout.itemview_hotsearch_listview)
public class ItemView_HotSearch_ListView extends LinearLayout {
    private Context context;
    @ViewById
    TextView itemview_hotsearch_listview_name,
            itemview_hotsearch_listview_text_annotation;

    @ViewById
    ImageView itemview_hotsearch_listview_image;

    public ItemView_HotSearch_ListView(Context context) {
        super(context);
        this.context = context;
    }

    public ItemView_HotSearch_ListView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    public ItemView_HotSearch_ListView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
    }

    public void bind(String name,String english,String shiyingzhen,String imageURL)
    {
        if (shiyingzhen.isEmpty())
            shiyingzhen = "暂无";
        itemview_hotsearch_listview_name.setText(name+"("+english+")");
        if (english.isEmpty())
        {
            itemview_hotsearch_listview_name.setText(name);
        }
        itemview_hotsearch_listview_text_annotation.setText(Html.fromHtml(shiyingzhen).toString());
        if (imageURL==null || imageURL.isEmpty())
            itemview_hotsearch_listview_image.setImageBitmap(BaseDataManager.getMyBaseDataManager(context)
                    .getResDrawable(testDate.defaultMedicationImage, ImageTool.dip2px(context,50),ImageTool.dip2px(context,50)));
        else
        {
            //缺少
        }
    }
}
